﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace HigLabo.Net.Twitter
{
    /// <summary>
    /// 
    /// </summary>
    public partial class TwitterClient
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public StatusCollection GetRetweets(Int64 id)
        {
            return this.GetRetweets(new GetRetweetsCommand(id));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public StatusCollection GetRetweets(GetRetweetsCommand command)
        {
            String url = String.Format(TwitterApiUrl.Version1_1.Tweets.GetRetweetsFormatUrl, command.ID);
            String jsonText = this.GetResultText(url, command);
            return new StatusCollection(jsonText);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public Status GetStatus(Int64 id)
        {
            GetRetweetCommand command = new GetRetweetCommand(id);
            return GetStatus(command);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public Status GetStatus(GetRetweetCommand command)
        {
            String jsonText = this.GetResultText(TwitterApiUrl.Version1_1.Tweets.GetShowFormatUrl, command);
            return new Status(jsonText);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public Status DestroyStatus(Int64 id)
        {
            return DestroyStatus(new RetweetCommand(id));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public Status DestroyStatus(RetweetCommand command)
        {
            String url = String.Format(TwitterApiUrl.Version1_1.Tweets.DestroyFormatUrl, command.ID);
            String jsonText = this.GetResultText(HttpMethodName.Post, url, command);
            return new Status(jsonText);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Status RetweetStatus(Int64 id)
        {
            return RetweetStatus(new RetweetCommand(id));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public Status RetweetStatus(RetweetCommand command)
        {
            String url = String.Format(TwitterApiUrl.Version1_1.Tweets.RetweetFormatUrl, command.ID);
            String jsonText = this.GetResultText(HttpMethodName.Post, url, command);
            return new Status(jsonText);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="tweetText"></param>
        /// <returns></returns>
        public Status UpdateStatus(String tweetText)
        {
            var cm = new UpdateStatusCommand();
            cm.Status = tweetText;
            return this.UpdateStatus(cm);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public Status UpdateStatus(UpdateStatusCommand command)
        {
            String jsonText = this.GetResultText(HttpMethodName.Post, TwitterApiUrl.Version1_1.Tweets.UpdateFormatUrl, command);
            return new Status(jsonText);
        }
    }
}
